package cn.itcast.classSM.web.action;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Controller;

import cn.itcast.classSM.domain.MainCheckMessage;
import cn.itcast.classSM.service.TeacherService;
import cn.itcast.classSM.web.action.common.BaseAction;

@ParentPackage("json-default")
@Namespace("/")
@Actions
@Controller
@Scope("prototype")
public class TeacherAction extends BaseAction<MainCheckMessage> {
	@Autowired
	private TeacherService teacherService;

	// 添加表信息
	@Action(value = "teacher_add", results = { @Result(name = "success", type = "redirect", location = "") })
	public String addTeacher() {
		teacherService.add(model);
		return "success";
	}

	// 查询表信息

	private String times;

	public void setTimes(String times) {
		this.times = times;
	}

	@Action(value = "teacher_findByMessage", results = { @Result(name = "success", type = "redirect", location = "") })
	public String findTeacher() {
		teacherService.findByMessage(model.getMcmClazz().getCid(), times);
		
		return "";
	}

}
